﻿using System.Windows;

using iStudio.Structure.Message;
using iStudio.View;

namespace iStudio.Library
{
    public class UiClient : MessageClient
    {
        public override void OnNext (Message value)
        {
            if (value is MessageDialog)
            {
                MessageDialog msg = (MessageDialog) value;

                ((MainWindow)Application.Current.MainWindow).OpenDockableWindow (msg.Dialog);
            }
            else
            {
                //
                // UiClient handles console logs
                //

                if (value.Parameters.Length == 2)
                {
                    if (value.Parameters[0].ToString () == "ConsoleLog")
                    {
                        ((MainWindow)Application.Current.MainWindow).ConsoleLog (value.Parameters[1].ToString ());
                    }
                }
            }
        }

        public override void OnError (System.Exception error)
        {
            
        }
    }
}
